<template>
	<view class="container">
		<view class="hzimg">
			<image src="/static/hjzx.jpg"></image>
			<view class="hzText">
				{{ app.language.ldy_dengji }}
			</view>
		</view>
		<!-- <view class="listBox" v-if="isShow"> -->
		<view class="listBox">
			<!-- 户籍办理提交记录 -->
			<view class="listText" @click="listText">
				<text>{{app.language.listText1}}</text>
			</view>
			<!-- 旅店业登记 -->
			<view class="hjzxBox">
				<!-- 信息不存在 -->
				<view class="listItem" v-if="hkzxList[0].id=='1'">
					<view class="list" @click="handleHkzx(hkzxList[0])">
						<!-- <image :src="hkzxList[0].icon"></image> -->
						<text class="listName">{{hkzxList[0].name}}</text>
						<image src="/static/ms.png"></image>
					</view>
				</view>
				<view class="listItem" v-if="hkzxList[0].id=='1'">
					<view class="uulist">
						<!-- <image :src="hkzxList[1].icon"></image> -->
						<text class="listName">{{hkzxList[1].name}}</text>
						<image src="/static/ms.png"></image>
					</view>
				</view>
				<view class="listItem" v-if="hkzxList[0].id=='1'">
					<view class="uulist">
						<!-- <image :src="hkzxList[2].icon"></image> -->
						<text class="listName">{{hkzxList[2].name}}</text>
						<image src="/static/ms.png"></image>
					</view>
				</view>
				<view class="listItem" v-if="hkzxList[0].id=='1'">
					<view class="uulist">
						<!-- <image :src="hkzxList[3].icon"></image> -->
						<text class="listName">{{hkzxList[3].name}}</text>
						<image src="/static/ms.png"></image>
					</view>
				</view>
				<!-- 信息存在 -->
				<view class="listItem" v-for="(item, index) in hkzxList" v-if="hkzxList[0].id!=='1'">
					<view class="list" @click="handleHkzx(item)">
						<!-- <image :src="item.icon"></image> -->
						<text class="listName">{{item.name}}</text>
						<image src="/static/ms.png"></image>
					</view>
				</view>
			</view>
		</view>
		<!-- <uni-popup ref="popup" type="bottom" border-radius="10px 10px 0 0" class="popup">
			<view class="infoBox">
				<button class="infoBtn" @click="infoBtn">{{ app.language.qxwsjbxx }}</button>
			</view>
		</uni-popup> -->
	</view>
</template>

<script>
	const global = getApp().globalData;
	import {
		GetHotelInfo,
		GetHotelCyInfo,
		GetHotelQtInfo
	} from '@/api/form.js'
	export default {
		data() {
			return {
				rlsb: true,
				app: {
					global: global,
					name: global.appName,
					language: global.language
				},
				// 旅店业登记
				hkzxList: [{
						id: "1",
						icon: "/static/hj.png",
						path: "/pages/hotel/index",
						name: ""
					},
					{
						icon: "/static/ld.png",
						path: "/pages/hotel/minorReg",
						name: ""
					},
					{
						icon: "/static/ld.png",
						path: "/pages/hotel/NotCard",
						name: ""
					},
					{
						icon: "/static/ld.png",
						path: "/pages/hotel/visitor",
						name: ""
					},
				],
				token: "",
				isShow: false,
				type: 'top',
				hffuuid: "",
				userInfo: {}
			}
		},
		onLoad() {
			this.hkzxList[0].name = this.app.language.ldyInfo
			this.hkzxList[1].name = this.app.language.wcnInfo
			this.hkzxList[2].name = this.app.language.wxdInfo
			this.hkzxList[3].name = this.app.language.fkInfo
			this.getToken()
			// 旅店业基本信息
			setTimeout(() => {
				this.GetHotel()
			}, 10); // 2000毫秒后执行
		},

		methods: {
			// 获取缓存
			getToken() {
				let that = this
				uni.getStorage({
					key: 'loginData',
					success: function(res) {
						that.token = res.data.userInfo.appToken
						that.userInfo = res.data.userInfo
					}
				});
			},

			// 获取基本信息
			GetHotel() {
				console.log('this.token', this.token)
				uni.showLoading({
					title: this.app.language.jzz,
				});
				let data = {
					appToken: this.token
				}
				GetHotelInfo(data).then((res) => {
					if (res.code == 200) {
						if (res.data.hotelBaseList && res.data.hotelBaseList.length > 0) {
							if (res.data.hotelBaseList[0].examineStatus == '1') {
								this.hffuuid = res.data.hotelBaseList[0].uuid
								this.hkzxList[0].id = res.data.hotelBaseList[0].uuid
							} else if (res.data.hotelBaseList[0].examineStatus == '0') {
								this.hffuuid = res.data.hotelBaseList[0].uuid
								this.hkzxList[0].id = "0"
							} else {
								this.hkzxList[0].id = "1"
								// this.$refs.popup.open('center')
							}
						}
						uni.hideLoading();
					}
				})
			},

			handleHkzx(item) {
				if (this.token) {
					if (this.userInfo.peopleType == "people") {
						if (!this.userInfo.userName && !this.userInfo.idcard &&
							!this.userInfo.idcardFront && !this.userInfo.idcardBack) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						} else {
							uni.navigateTo({
								url: item.path + '?hffuuid=' + this.hffuuid
							});
						}
					} else if (this.userInfo.peopleType == "police") {
						// 身份作证号的
						if (!this.userInfo.agent) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.birthdate) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.idcard) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.nationality) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.policeNumber) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.personnelCategory) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.workTime) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.positionRank) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.marriage) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.height) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.weight) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						if (!this.userInfo.photo) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						}
						uni.navigateTo({
							url: item.path + '?hffuuid=' + this.hffuuid
						});
					}
				} else {
					uni.navigateTo({
						url: '../login/login',
					});
				}
			},

			handleKf() {
				console.log('我要咨询')
			},
			infoBtn() {
				uni.navigateTo({
					url: '/pages/hotel/index'
				});
			},
			listText() {
				if (this.token) {
					if (this.userInfo.peopleType == "people") {
						if (!this.userInfo.userName && !this.userInfo.idcard &&
							!this.userInfo.idcardFront && !this.userInfo.idcardBack) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						} else {
							uni.reLaunch({
								url: '/pages/hotel/listText'
							});
						}
					} else if (this.userInfo.peopleType == "police") {
						if (!this.userInfo.agent && !this.userInfo.birthdate && !this.userInfo.birthdate && !this
							.userInfo
							.nationality && !this.userInfo.policeNumber &&
							!this.userInfo.personnelCategory && !this.userInfo.department && !this.userInfo.workTime &&
							!
							this.userInfo.positionRank &&
							!this.userInfo.marriage && !this.userInfo.height && !this.userInfo.weight && !this.userInfo
							.photo) {
							uni.showToast({
								title: this.app.language.improve,
								icon: 'none',
							});
							return
						} else {
							uni.reLaunch({
								url: '/pages/hotel/listText'
							});
						}
					}
				} else {
					uni.navigateTo({
						url: '../login/login',
					});
				}
			},
		}
	}
</script>

<style>
	.listItem {
		margin: 10rpx 0;
		border-bottom: 1px dashed #ddd;
		padding-bottom: 10rpx;
	}

	.listBox {
		padding: 0 20rpx;
	}

	.list text,
	.uulist text {
		width: 89%;
		display: inline-block;
		font-size: 26rpx;
		padding-left: 5rpx;
	}

	.uulist text {
		color: #999;
	}

	.list image,
	.uulist image {
		width: 30rpx;
		height: 30rpx;
		position: relative;
		top: 5rpx;
		float: right;
	}

	.hzimg image {
		width: 100%;
		height: 222rpx;
	}

	.hzText {
		position: absolute;
		top: 70rpx;
		left: 137rpx;
		font-size: 44rpx;
		color: #2f8ef9;
	}

	.hjTitle {
		font-size: 30rpx;
		margin: 20rpx 0;
		font-weight: bold;
	}

	.hjzxBox {
		margin-bottom: 15rpx;
		box-shadow: 2rpx 2rpx 20rpx #ddd;
		padding: 10rpx 10rpx 5rpx;
	}

	.kfBox {
		background-color: #2f8ef9;
		color: #fff;
		font-size: 22rpx;
		text-align: center;
		width: 100rpx;
		height: 100rpx;
		padding: 20rpx;
		border-radius: 50%;
		box-shadow: 1px 1px 10rpx #ddd;
		position: absolute;
		bottom: 40rpx;
		right: 0;
	}

	.kfBox image {
		width: 60rpx;
		height: 60rpx;
	}

	.infoBox {
		/* background-color: #fff;
		width: 500rpx;
		border-radius: 12rpx;
		text-align: center;
		padding: 38rpx; */
	}

	.
	/* popup{
		width: 100%;
	} */

	.infoBtn {
		background-color: #2f8ef9;
		color: #fff;
		font-size: 24rpx;
	}

	.listText {
		font-size: 28rpx;
		color: #2f8ef9;
		margin: 15rpx 0;
		text-align: right;
		font-weight: 500;
		/* border-bottom: 1px solid #ddd; */
		padding-bottom: 10rpx;
	}

	.listText text {
		border: 1px solid #2f8ef9;
		padding: 10rpx 15rpx;
		border-radius: 6rpx;
	}
</style>